function rnk(n,k:longint):longint; // TO GO: ans:=rnk(n,n);

var
  i,sum:longint;
 
begin
result:=0;
if n=0 then result:=1 else begin
  k:=min(n,k);
  for i:=1 to k do
    inc(result,rnk(n-i,i));
end;
end;

function rnk(n:longint):longint;

const
        kk=3;
        a:array[1..kk] of longint=(1,2,6);

var
        i,j:longint;
        f:array[-10..110,0..kk] of longint;
        
begin
fillchar(f,sizeof(f),0);
for i:=0 to kk do
        f[0][i]:=1;
for i:=1 to n do
        for j:=1 to kk do
                        f[i][j]:=f[i-a[j]][j]+f[i][j-1];
result:=f[n][kk];
end;